/*
 * @Author: szx
 * @Date: 2022-05-21 13:13:15
 * @LastEditTime: 2022-05-21 13:15:34
 * @Description:
 * @FilePath: \leetcode\100-199\169\169.js
 */
/**
 * @param {number[]} nums
 * @return {number}
 */
var majorityElement = function (nums) {
    let res,
        cnt = 0;
    for (let num of nums) {
        if (cnt == 0) {
            res = num;
        } else {
            if (res == num) cnt++;
            else cnt--;
        }
    }
    return res;
};
